<!--#
layout("/layouts/store.html"){
#-->
<script src="${base!}/assets/store/vendor/ueditor/ueditor.config.js"></script>
<script src="${base!}/assets/store/vendor/ueditor/ueditor.all.js"></script>
<header class="header navbar bg-white shadow">
    <div class="btn-group tool-button">
        <a class="btn btn-primary navbar-btn" href="${base}/store/shop/adv/main" id="goBack" data-pjax><i class="ti-angle-left"></i>${msg['globals.button.back']}</a>
    </div>
</header>

<div class="content-wrap">
    <div class="wrapper" style="min-height:500px;">
        <section class="panel panel-form">
            <form id="addForm" role="form" class="form-horizontal parsley-form" data-parsley-validate
                  action="${base}/store/shop/adv/main/addDo" method="post">
                <div class="row mb10 mt10">
                    <div class="col-lg-12">
                        <div class="form-group">
                            <label for="positionId" class="col-sm-2 control-label">${msg['shop.adv.main.column.positionId']}</label>
                            <div class="col-sm-8">
                                <select type="text" id="positionId" name="positionId" class="form-control">
                                    <!--# for(o in list){
                #-->
                                    <option value="${o.id}">${o.name}</option>
                                    <!--#
                    }#-->
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="title" class="col-sm-2 control-label">${msg['shop.adv.main.column.title']}</label>
                            <div class="col-sm-8">
                            <input type="text" id="title" class="form-control" name="title" data-parsley-required="true" placeholder="${msg['shop.adv.main.column.title']}">
                            </div>
                        </div>
                        <!--<div class="form-group">
                            <label for="imgurl" class="col-sm-2 control-label">${msg['shop.adv.main.column.imgurl']}</label>
                            <div class="col-sm-8">
                            <input type="text" id="imgurl" class="form-control" name="imgurl" data-parsley-required="true" placeholder="${msg['shop.adv.main.column.imgurl']}">
                            </div>
                        </div>-->
                        <div class="form-group">
                            <label for="imgurl" class="col-sm-2 control-label">${msg['shop.adv.main.column.imgurl']}</label>

                            <div class="col-sm-6">
                                <div id="queue"></div>
                                <div>
                                    <input id="file_upload" name="file_upload" type="file"
                                           multiple="false">
                                </div>
                                <div id="img" style="padding: 5px;"></div>
                                <input type="hidden" id="imgurl" name="imgurl" value="">
                            </div>
                            <div class="col-sm-2" style="color: red;">建议尺寸：375*200</div>
                        </div>
                        <div class="form-group">
                            <label for="url" class="col-sm-2 control-label">${msg['shop.adv.main.column.url']}</label>
                            <div class="col-sm-8">
                            <input type="text" id="url" class="form-control" name="url" data-parsley-required="true" placeholder="${msg['shop.adv.main.column.url']}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="at" class="col-sm-2 control-label">${msg['shop.adv.main.column.startAt']}</label>

                            <div class="col-sm-8 input-group date form_datetime "
                                        style="padding-left: 16px; padding-right: 16px;"
                                        data-date="1979-09-16T05:25:07Z"
                                        data-date-format="dd MM yyyy - HH:ii p" data-link-field="at">
                            <input type="text" size="16" readonly class="form-control"
                                   value="${@date.getDateTime()}" data-parsley-required="true">
                            <span class="input-group-addon"><span
                                    class="glyphicon glyphicon-remove"></span></span> <span
                                class="input-group-addon"><span
                                class="glyphicon glyphicon-th"></span></span>
                        </div>
                            <input type="hidden" id="at" name="at"
                                   value="${@date.getDateTime()}" />
                        </div>
                        <div class="form-group">
                            <label for="end" class="col-sm-2 control-label">${msg['shop.adv.main.column.endAt']}</label>

                             <div class="col-sm-8 input-group date form_datetime "
                                 style="padding-left: 16px; padding-right: 16px;"
                                 data-date="1979-09-16T05:25:07Z"
                                 data-date-format="dd MM yyyy - HH:ii p" data-link-field="end">
                                <input type="text" size="16" readonly class="form-control"
                                       value="${@date.getDateTime()}" data-parsley-required="true">
                                <span class="input-group-addon"><span
                                        class="glyphicon glyphicon-remove"></span></span> <span
                                    class="input-group-addon"><span
                                    class="glyphicon glyphicon-th"></span></span>
                            </div>
                            <input type="hidden" id="end" name="end"
                                   value="${@date.getDateTime()}" />
                        </div>
                        <div class="form-group">
                            <label for="location" class="col-sm-2 control-label">${msg['shop.adv.main.column.location']}</label>
                            <div class="col-sm-8">
                            <input type="number" id="location" class="form-control" name="location" data-parsley-required="true" placeholder="${msg['shop.adv.main.column.location']}">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-3"></div>
                <div class="col-lg-6">
                    <div class="form-group text-center">
                        <label></label>

                        <div>
                            <button id="save" class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="${msg['globals.button.submit.tip']}">${msg['globals.button.submit']}</button>
                        </div>
                    </div>
                </div>
            </form>
        </section>
    </div>
</div>
<script language="JavaScript">
    function clearFile() {
        $("#img").html("");
        $("#queue").html("");
        $("#imgurl").val("");
    }
    $(document).ready(function () {
        $('.form_datetime').datetimepicker({
            format:'yyyy-mm-dd hh:ii:ss',
            weekStart: 1,
            todayBtn:  1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            showMeridian: 1
        });
        $('#file_upload').uploadifive({
            'auto': true,
            'multi': false,
            'width': '100%',
            'height': '35',
            'buttonText': '${msg['cms.article.column.selectpicture']}',
            'fileType': 'image/jpg,image/jpeg,image/png',
            'fileSizeLimit': 1024,
            'queueSizeLimit': 1,
            'formData': {},
        'queueID': 'queue',
            'uploadScript': '${base}/open/file/upload/image',
            'onUploadComplete': function (file, data) {
            data = JSON.parse(data);
            if (data.code == 0) {
                Toast.success(data.msg);
                $("#img").html("<img src='" + data.data + "' style='width:150px;height:95px;'>");
                $("#imgurl").val(data.data);
            } else {
                clearFile();
                Toast.error(data.msg);
            }
        },
        'onDrop': function (file, fileDropCount) {
            clearFile();
        },
        'onClearQueue': function (queue) {
            clearFile();
        },
        'onCancel': function () {
            clearFile();
        }
    });
        $('#addForm').ajaxForm({
            dataType: 'json',
            beforeSubmit: function (arr, form, options) {
                form.find("button:submit").button("loading");
            },
            success: function (data, statusText, xhr, form) {
                if (data.code == 0) {
                    // Toast.success(data.msg);
                    // form.resetForm();
                    window.location.href = "${base}/store/shop/adv/main";
                } else {
                    Toast.error(data.msg);
                }
                form.find("button:submit").button("reset");
            }
        });
    });
</script>
<!--#}#-->


